#include <stdio.h>

int gcd( int x, int y );

int main()
{
    int x, y;
    
    scanf("%d %d", &x, &y);
    printf("%d\n", gcd(x, y));
    
    return 0;
}

int gcd( int x, int y )
{
	int i, min = x, gcd = 0;
	if(y<=x)
	{
		min = x;
	} 
	for(i = min; i > 0; i--)
	{
		if(x % i == 0 && y % i == 0)
		{
			gcd = i;
			break;
		}
	}
	return gcd;
}
